// 使用reverse 
// const myCompose = (...args) => v => args.reverse().reduce((acc, fn) => fn(acc), v)

// 另一种写法
const myCompose = (...funcs) => v => funcs.reduce((acc, fn) => acc(fn(v)))




let sayHello = (...str) => `Hello , ${str.join(" And ")} a`;
let toUpper = str => str.toUpperCase();
let combin = myCompose(
  sayHello,
  toUpper
);
console.log(combin('jack', 'bob'))





console.log('start here')
const foo = () => (new Promise((resolve, reject) => {
  console.log('first promise constructor')
  let promise1 = new Promise((resolve, reject) => {
    console.log('second promise constructor')
    setTimeout(() => {
      console.log('setTimeout herer')
      resolve()
    }, 0)
    resolve('promise1')
  })
  resolve('promise0')
  promise1.then(arg => { console.log(arg) })
}))
foo().then((arg) => console.log(arg))

console.log('end here')